package com.ruoyi.framework.security.filter;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import java.util.Collections;

/**
 * openapi的认证信息
 */
public class OpenApiAuthenticationToken extends AbstractAuthenticationToken {

    private final String appKey;
    private final String appName;

    public OpenApiAuthenticationToken(String appKey, String appName) {
        super(Collections.singletonList(new SimpleGrantedAuthority("ROLE_API_USER")));
        this.appKey = appKey;
        this.appName = appName;
        setAuthenticated(true); // 标记为已认证
    }

    @Override
    public Object getCredentials() {
        return null;
    }

    @Override
    public Object getPrincipal() {
        return appKey;
    }

    public String getAppKey() {
        return appKey;
    }

    public String getAppName() {
        return appName;
    }
}
